/**
 * Created by Administrator on 2019/1/11.
 */
package com.game.fg.service;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;


public class FGRedis {

    private static FGRedis r = new FGRedis();

    public static FGRedis getInstance() {
        return r;
    }

    private JedisPool pool = null;

    void start() {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(10);//最大连接数，连接全部用完，进行等待
        poolConfig.setMinIdle(0); //最小空余数
        poolConfig.setMaxIdle(0); //最大空余数
        pool = new JedisPool(poolConfig, FGConfig.getInstance().serverConfig.getRedisHost(), FGConfig.getInstance().serverConfig.getRedisPort());
    }


    Jedis getJedis() {
        Jedis jedis = pool.getResource();
        jedis.auth(FGConfig.getInstance().serverConfig.getRedisPassword());
        return jedis;
    }

}
